<?php


namespace App\Http\Controllers\Forwarder;


use App\Http\Controllers\Controller;
use App\Models\ForwarderFollow;
use Illuminate\Http\Request;

class ForwarderFollowController extends Controller
{
    public function index(Request $request)
    {
        $list = ForwarderFollow::paginate();
        return $this->response($list);
    }

    public function store(Request $request, ForwarderFollow $obj)
    {
        $forwarderFollow = ForwarderFollow::where('forwarder_id', $request->input('forwarder_id'))
            ->where('user_id', $request->user()->id)->first();
        if(is_object($forwarderFollow)){
            return $this->response();
        }
        $all = $request->all();
        $obj->fill($all);
        $obj->user_id = $request->user()->id;
        $obj->save();
        return $this->response();
    }


    public function destroy($id)
    {
        $obj = ForwarderFollow::find($id);
        $obj->delete();
        return $this->response();
    }
}
